package cn.tedu.car.backend.user.controller;

import cn.tedu.car.backend.base.response.JsonResult;
import cn.tedu.car.backend.user.pojo.dto.LoginDTO;
import cn.tedu.car.backend.user.pojo.vo.LoginVO;
import cn.tedu.car.backend.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统用户登录控制器
 */
@Api(tags = "系统用户登录控制器")
@Slf4j
@RestController
@RequestMapping("/v1/")
public class LoginController {
    @Autowired
    private UserService userService;

    @ApiOperation("登录")
    @PostMapping("login")
    public JsonResult login(@Validated LoginDTO loginDTO) {
        log.debug("用户登录参数：{}", loginDTO);
        LoginVO loginVO = userService.login(loginDTO);
        return JsonResult.ok(loginVO);
    }
}
